<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
/**
 * 用户模型
 */
class Gongyibi_transfer_details_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	
	/**
	 *
	 */
	public function out_list_all($page,$perpage,$user_id) {
		$sql = " select * from pc_ddth_gongyibi_details where uid='$user_id' order by id desc limit ".$perpage*($page-1).",$perpage ";
		
		$query = $this->db->query ( $sql );
	
		return $query->result_array ();
	}
	
	/**
	 * 新增公益币转账记录
	 */
	public function transfer_details_add($uid, $transfer_type, $account1, $account2, $bianhao) {
		$data = array (
				'transfer_type' => $transfer_type,
				'number' => $_POST ['number'],
				'uid' => $uid,
				'account1' => $account1,
				'account2' => $account2,
				'create_time' => time (),
				'bianhao' => $bianhao 
		);
		
		$result = $this->db->insert ( 'pc_ddth_gongyibi_details', $data );
		
		return $result;
	}
	
	/**
	 * 查询所有公益币转账记录
	 */
	public function details_list($uid = FALSE) {
		if ($uid === FALSE) {
			$query = $this->db->get ( 'pc_ddth_gongyibi_details' );
			return $query->result_array ();
		}
		
		$query = $this->db->get_where ( 'pc_ddth_gongyibi_details', array (
				'uid' => $uid 
		) );
		return $query->result_array ();
	}
	
	/**
	 *
	 */
	public function out_list_all_count($user_id) {
		$query = $this->db->get_where ( 'pc_ddth_gongyibi_details', array (
				'uid' => $user_id 
		) );
	
		return count($query->result_array ());
	}
}